/*============================================================================*/
/*                        Tortoise Team			                              */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* C Include:        %MAL_PWM.h%
* Instance:         RPL_1
* %version:         1 %
* %created_by:      Andres Torres Garcia %
* %date_created:    Sunday May 20 13:41:01 2012 %
*=============================================================================*/
/* DESCRIPTION : Header file for uC Abstraction layer for PWM                                */
/*============================================================================*/
/* FUNCTION COMMENT : Describes the functions for uC Abstraction Layer for PWM*/
/*   module														              */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*----------------------------------------------------------------------------*/
/*  1.0      | 25/05/2012  | SAR/SIF/SCN_xxx               | Andres Torres    */
/*	1.1		 | 15/09/2012  |							   | Andres Torres    */
/* Integration under Continuus CM                                             */
/*============================================================================*/

#ifndef MAL_PWM_H                               /* To avoid double inclusion */
#define MAL_PWM_H

/* Includes */
/* -------- */
#include "stdtypedef.h"
#include "MAL_EMIOS.h"

/* Exported types and constants */
 /* ---------------------------- */
 
 /*!
  \def COUNTER_BUS_BCDE
  Use the counter buses B, C, D and E as a counter.
*/
 #define COUNTER_BUS_BCDE	0x1

/* Types definition */
/* typedef */

/*==================================================*/ 
/* Declaration of exported constants                */
/*==================================================*/ 
/* BYTE constants */

/* WORD constants */

/* LONG and STRUCTURE constants */


/*======================================================*/ 
/* Definition of RAM variables                          */
/*======================================================*/ 
/* BYTES */

/* WORDS */

/* LONGS and STRUCTURES */

/*======================================================*/ 
/* close variable declaration sections                  */
/*======================================================*/ 

/* Exported functions prototypes and macros */
/* ---------------------------------------- */

/* Functions prototypes */

/*! Init and start a PWM in a specific channel and pin.
   \param ub_dutyChannel The channel of the PWM.
   \param uw_dutyCycle The dutycycle value in us.
   \param ub_periodChannel The channel of the counter.
   \param uw_period The period value in us.
   \param ub_counterBus Select which counter bus is going to use as a period of time   
   \param ub_pinPcr The pin of the PWM.
   \sa Version 
  */
extern void vfnInitPWMChannel(T_UBYTE ub_dutyChannel, T_UWORD uw_dutyCycle, T_UBYTE ub_periodChannel, T_UWORD uw_period, T_UBYTE ub_counterBus, T_UBYTE ub_pinPcr);

/*! Init a out of phase PWM channel in a specific channel and pin.
   \param ub_dutyChannel The channel of the PWM.
   \param uw_registerA Value of register A in us.
   \param uw_registerB Value of register B in us.
   \param ub_periodChannel The channel of the counter.
   \param uw_period The period value in us.
   \param ub_counterBus Select which counter bus is going to use as a period of time   
   \param ub_pinPcr The pin of the PWM.
   \sa Version 
  */
extern void vfnInitPWM_Out_Of_Phase(T_UBYTE ubChannel, T_UWORD uw_registerA, T_UWORD uw_registerB, T_UBYTE ub_periodChannel, T_UWORD uw_period, T_UBYTE ub_counterBus, T_UBYTE ub_pinPcr);

/*! Init a simple capture PWM in a specific channel and pin.
   \param ubChannel The channel of the PWM.
   \param ub_periodChannel The channel of the counter.
   \param uw_period The period value in us.
   \param ub_counterBus Select which counter bus is going to use as a period of time   
   \param ub_pinPcr The pin of the PWM.
   \param ubPol Selects polarity that the PWM must capture.
   \sa Version 
  */
extern void vfnInitPWM_Simple_Capture(T_UBYTE ubChannel, T_UBYTE ub_periodChannel, T_UWORD uw_period, T_UBYTE ub_counterBus, T_UBYTE ub_pinPcr, T_UBYTE ubPol);

/*! Set up the clock of the PWM.
   \sa Version 
  */
extern void vfnSetUpClock(void);


/*! Set the duty cycle fo a specific channel
   \param ub_channel The channel.
   \param uw_dutyCycle The duty cycle in us.
   \sa Version 
  */
extern void vfnSetDutyCycle(T_UBYTE ub_channel, T_UWORD uw_dutyCycle);

/* Functions macros */

/* Exported defines */

/*!
  \def START_COUNTING()
  Enable the clock of the PWM
*/
#define START_COUNTING()	(ENABLE_EMIOS_0())	

#endif


